export const useQueryTable = (callback: Function) => {
  let searchInfo: any = reactive({
    page: 1,
    limit: 10
  });

  let loading = ref(false); /* 加载中 */
  let loadingBtn = ref(false); /* 按钮加载中 */
  let total = ref(0); /* 表格数据总数 */
  let tableData = ref<any[]>([]); /* 表格数据 */

  /**
   * 切换表格每页数
   * @param val 表格每页数量
   */
  const handleSizeChange = (val: number) => {
    searchInfo.limit = val;
    callback();
  };

  /**
   * 切换表格分页
   * @param val 表格切换页数
   */
  const handleCurrentChange = (val: number) => {
    searchInfo.page = val;
    callback();
  };

  /**
   * 表格样式
   * @param param0 
   */
  const cellStyle = ({ row, column }: any): any => {
    if (row[column.property] == null || row[column.property] === '') {
      row[column.property] = '-';
    }
  };


  return {
    searchInfo,
    loading,
    loadingBtn,
    total,
    tableData,
    handleSizeChange,
    handleCurrentChange,
    cellStyle
  }
}